package thread;

import java.util.concurrent.TimeUnit;

import static print.Print.*;

public class SimpleDaemons implements Runnable {


    @Override
    public void run() {
        try{
            TimeUnit.MILLISECONDS.sleep(3000);
            print(Thread.currentThread()+" "+this);
        }catch (InterruptedException ex){
            print(ex);
        }
    }

    public static void main(String[] args) throws Exception{
        for (int i =0;i < 10; i ++){
            Thread daemon = new Thread(new SimpleDaemons());
            daemon.setDaemon(true);
            daemon.start();
        }
        print("All daemons started");
        TimeUnit.MILLISECONDS.sleep(2000);
        print("All daemons ended");
    }
}
